import Vue from 'vue'
import Store from "../store"
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import Layout from "@/layout/index.vue"
let defaultRoutes = [
    {
        path: '/login',
        component: () => import('../views/login/index.vue'),
        hidden: true
    },

    {
        path: '/',
        component: Layout,
        redirect: '/home',


    },
    //所以自己的路由下载下面,上面两个顺序不可动,如要改动,请到layout/component中router.options.routes.slice(2)字段修改
    //一下用来鉴权之前的测试
    // {
    //     path: "/home",
    //     redirect: "/home/nav",
    //     component: Layout,
    //     meta: { title: "主页", Icon: "layui-icon layui-icon-login-wechat" },
    //     children: [
    //         {
    //             path: "/home/details",
    //             name: "details",
    //             component: () => import("../views/details.vue"),
    //             meta: { title: "使用须知", Icon: "layui-icon layui-icon-login-qq" }

    //         },
    //         {
    //             path: "/home/nav",
    //             name: "Nav",
    //             component: () => import("../views/nav.vue"),
    //             meta: { title: "首页", Icon: "layui-icon layui-icon-login-qq" }

    //         }, {
    //             path: "/home/tt",
    //             name: "tt",
    //             component: () => import("../views/about.vue"),
    //             meta: { title: "关于", Icon: "layui-icon layui-icon-login-qq" }

    //         }, {
    //             path: "/home/fwb",
    //             name: "fwb",
    //             component: () => import("../views/wangeditor.vue"),
    //             meta: { title: "富文本", Icon: "layui-icon layui-icon-login-qq" }

    //         },
    //         {
    //             path: "/home/echarts",
    //             name: "echarts",
    //             component: () => import("../views/echarts.vue"),
    //             meta: { title: "图表展示", Icon: "layui-icon layui-icon-login-qq" }

    //         },
    //     ]
    // },

    // {
    //     path: "/about",
    //     name: "About",
    //     redirect: "/about/nav",

    //     component: Layout,
    //     meta: { title: "账号注册", Icon: "layui-icon layui-icon-login-weibo" },
    //     children: [
    //         {
    //             path: "/about/nav",
    //             name: "Nav",
    //             component: () => import("../views/nav.vue"),
    //             meta: { title: "素材", Icon: "layui-icon layui-icon-login-qq" }

    //         }, {
    //             path: "/abou/ttt",
    //             name: "tt",
    //             component: () => import("../views/about.vue"),
    //             meta: { title: "其他", Icon: "layui-icon layui-icon-login-qq" }

    //         },
    //     ]

    // },


]
let routes =  defaultRoutes.concat(Store.state.stateRouter)


const router = new VueRouter({
    routes
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router